package xtreamclient


import kotlin.random.Random
import com.eeeeeric.mpc.hc.api.FileInfo
import java.io.RandomAccessFile


val streamsold = listOf(
    "https://www.youtube.com/watch?v=6P20npkvcb8",
    "https://www.youtube.com/watch?v=H_oGi8uuDpA",
    "https://www.youtube.com/watch?v=F9UC9DY-vIU",
    "https://www.youtube.com/watch?v=ei66Fr25Y2M",
    "https://www.youtube.com/watch?v=sZWMPYIkNd8"

)

val streams = listOf(
    "http://tv.tvtech.xdns.pro:80/TYDEDaniel/an1ye6720/12519",
    "http://tv.tvtech.xdns.pro:80/TYDEDaniel/an1ye6720/1642",
    "http://tv.tvtech.xdns.pro:80/TYDEDaniel/an1ye6720/16487",
    "http://tv.tvtech.xdns.pro:80/TYDEDaniel/an1ye6720/15759",
    "http://tv.tvtech.xdns.pro:80/TYDEDaniel/an1ye6720/15759"



)



fun main() {
    /*
    val vlcHandler = MPVHandler()
    vlcHandler.connect()
    val rand = Random.Default

    while(true) {
        Thread.sleep(1500)
        val index = rand.nextInt(0,streams.size)
        vlcHandler.playItem(streams[index])
    }*/



    var pipe = RandomAccessFile("\\\\.\\pipe\\mpvsocket", "rw")

    val echoText = "{ \"command\": [\"loadfile\", \"${streams[4]}\"], \"request_id\": 100 }\n"
    pipe.write(echoText.toByteArray())

    val echoResponse = pipe.readLine();
    System.out.println("Response: " + echoResponse );
    pipe.close();
}